package AST;
import java.io.*;
import javax.swing.JFileChooser;



public class ASTTest {
	public static void main(String args[]){
		AST tree = new AST();
		JFileChooser first = new JFileChooser();
		first.showDialog(null, "Find the input file");	
		
		try{
			  FileInputStream fstream = new FileInputStream(first.getSelectedFile().getAbsolutePath());
			  DataInputStream in = new DataInputStream(fstream);
			  BufferedReader br = new BufferedReader(new InputStreamReader(in));
			  String strLine;
			  while ((strLine = br.readLine()) != null)   {
				  tree.addExpression(strLine);
				  System.out.println (strLine);
			  }
			  System.out.println("\n\n");
			  ASTReader astr = new ASTReader();
			  astr.evaluateTree(tree.getTree().get(0));
			  System.out.println(tree.toString());
			  in.close();
			    }catch (Exception e){
			  System.err.println("Error: " + e.getMessage());
			  }
		
	}
}
